package com.bxd.baodan.item;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.bxd.baodan.base.BaseItem;
import com.bxd.baodan.util.StringUtil;

/**
 * 问题
 * 
 * @author oldfeel
 * 
 *         Create on: 2014年7月7日
 */
@DatabaseTable
public class QuestionItem extends BaseItem {
	@DatabaseField(generatedId = true)
	private long id;
	@DatabaseField
	private long q_id;//问题id
	@DatabaseField
	private String q_title;//问题标题
	@DatabaseField
	private long u_id;//提问者id
	@DatabaseField
	private String city;//提问者省市
	@DatabaseField
	private String q_content;//问题内容 
	@DatabaseField
	private long q_answer_count;//问题回答数量
	@DatabaseField
	private String q_last_answer_date;//最近更新时间
	@DatabaseField
	private String q_update_date;//更新时间
	@DatabaseField
	private String u_nick;//提问者昵称
	@DatabaseField
    private String u_avatar;//提问者头像
	@DatabaseField
	private boolean isfav;//是否已被收藏
	private AnswerItem qa_answer_info;//回答者信息
	@DatabaseField
	private String answerInfoString;//回答者信息
	@DatabaseField
	private long time;
	@DatabaseField
	private boolean solved;//该问题是否已解决
	@DatabaseField
	private int type;//0：寿险  1：车险
	@DatabaseField
	private String keyLabel;//关键标签，用逗号分隔
	@DatabaseField
	private int count;//报价次数
	@DatabaseField
	private double verPrice;//平均价格
	@DatabaseField
	private boolean isRead;
	private long isBestAnswer;
	
	//--------------------以下属性现在不用------------------------
	private String q_supplement;
	private long q_view_count;
	private long q_visitor_count;
	private long q_last_agent_uid;
	private String q_create_date;
	private UserItem qa_user_info;
	private int q_type;
	private long p_id;
	
	
	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}
	/**
	 * @return the keyLabel
	 */
	public String getKeyLabel() {
		return keyLabel;
	}
	/**
	 * @param keyLabel the keyLabel to set
	 */
	public void setKeyLabel(String keyLabel) {
		this.keyLabel = keyLabel;
	}
	/**
	 * @return the count
	 */
	public int getCount() {
		return count;
	}
	/**
	 * @param count the count to set
	 */
	public void setCount(int count) {
		this.count = count;
	}
	/**
	 * @return the verPrice
	 */
	public double getVerPrice() {
		return verPrice;
	}
	/**
	 * @param verPrice the verPrice to set
	 */
	public void setVerPrice(double verPrice) {
		this.verPrice = verPrice;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public long getQ_id() {
		return q_id;
	}
	public void setQ_id(long q_id) {
		this.q_id = q_id;
	}
	public String getQ_title() {
		return q_title;
	}
	public void setQ_title(String q_title) {
		this.q_title = q_title;
	}
	public long getU_id() {
		return u_id;
	}
	public void setU_id(long u_id) {
		this.u_id = u_id;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getQ_content() {
		return q_content;
	}
	public void setQ_content(String q_content) {
		this.q_content = q_content;
	}
	public long getQ_answer_count() {
		return q_answer_count;
	}
	public void setQ_answer_count(long q_answer_count) {
		this.q_answer_count = q_answer_count;
	}
	public String getQ_last_answer_date() {
		return q_last_answer_date;
	}
	public void setQ_last_answer_date(String q_last_answer_date) {
		this.q_last_answer_date = q_last_answer_date;
	}
	public String getQ_update_date() {
		return q_update_date;
	}
	public void setQ_update_date(String q_update_date) {
		this.q_update_date = q_update_date;
	}
	public String getU_nick() {
		return u_nick;
	}
	public void setU_nick(String u_nick) {
		this.u_nick = u_nick;
	}
	public String getU_avatar() {
		return u_avatar;
	}
	public void setU_avatar(String u_avatar) {
		this.u_avatar = u_avatar;
	}
	public boolean isIsfav() {
		return isfav;
	}
	public void setIsfav(boolean isfav) {
		this.isfav = isfav;
	}
	public AnswerItem getQa_answer_info() {
		if (qa_answer_info == null) {
			qa_answer_info = new Gson().fromJson(getAnswerInfoString(), new TypeToken<AnswerItem>(){}.getType());
		}
		return qa_answer_info;
	}
	public void setQa_answer_info(AnswerItem qa_answer_info) {
		this.qa_answer_info = qa_answer_info;
	}
	public String getAnswerInfoString() {
		if (StringUtil.isEmpty(answerInfoString)) {
			answerInfoString = new Gson().toJson(qa_answer_info);
		}
		return answerInfoString;
	}
	public void setAnswerInfoString(String answerInfoString) {
		this.answerInfoString = answerInfoString;
	}
	public long getTime() {
		return time;
	}
	public void setTime(long time) {
		this.time = time;
	}
	public boolean isSolved() {
		return solved;
	}
	public void setSolved(boolean solved) {
		this.solved = solved;
	}
	public String getQ_supplement() {
		return q_supplement;
	}
	public void setQ_supplement(String q_supplement) {
		this.q_supplement = q_supplement;
	}
	public long getQ_view_count() {
		return q_view_count;
	}
	public void setQ_view_count(long q_view_count) {
		this.q_view_count = q_view_count;
	}
	public long getQ_visitor_count() {
		return q_visitor_count;
	}
	public void setQ_visitor_count(long q_visitor_count) {
		this.q_visitor_count = q_visitor_count;
	}
	public long getQ_last_agent_uid() {
		return q_last_agent_uid;
	}
	public void setQ_last_agent_uid(long q_last_agent_uid) {
		this.q_last_agent_uid = q_last_agent_uid;
	}
	public String getQ_create_date() {
		return q_create_date;
	}
	public void setQ_create_date(String q_create_date) {
		this.q_create_date = q_create_date;
	}
	public UserItem getQa_user_info() {
		return qa_user_info;
	}
	public void setQa_user_info(UserItem qa_user_info) {
		this.qa_user_info = qa_user_info;
	}
	public int getQ_type() {
		return q_type;
	}
	public void setQ_type(int q_type) {
		this.q_type = q_type;
	}
	public long getP_id() {
		return p_id;
	}
	public void setP_id(long p_id) {
		this.p_id = p_id;
	}
	
	
	@Override
	public String toString() {
		return super.toString();
	}
	public boolean isRead() {
		return isRead;
	}
	public void setRead(boolean isRead) {
		this.isRead = isRead;
	}
	public long getIsBestAnswer() {
		return isBestAnswer;
	}
	public void setIsBestAnswer(long isBestAnswer) {
		this.isBestAnswer = isBestAnswer;
	}
	
}
